<template>
  <!-- <el-popover
    placement="bottom"
    width="0"
    trigger="click"
  > -->

  <!-- <el-tabs v-model="activeName">
      <el-tab-pane
        label="邮件(1)"
        name="first"
      />
      <el-tab-pane
        label="消息(2)"
        name="second"
      />
      <el-tab-pane
        label="通知"
        name="third"
      />
    </el-tabs>
    <el-scrollbar style="height:300px">
      <avue-notice
        :data="data"
        :option="option"
        @page-change="pageChange"
      />
    </el-scrollbar> -->
  <div slot="reference">
    <el-badge :value="num" :max="99">
      <i class="el-icon-bell"/>
    </el-badge>
  </div>
  <!-- </el-popover> -->
</template>

<script>
import { auditRecordAll } from '@/api/ips/audit'
import eventbus from '@/utils/eventbus'

const list = []
export default {
  name: 'TopNotice',
  data() {
    return {
      num: 0,
      queryParams: {
        current: 1,
        size: 10,
        id: undefined,
        checkBy: '',
        status: undefined,
        type: '',
        isRead: 0
      }
    }
  },
  created() {
    this.getAll()
  },
  mounted() {
    eventbus.$on('websocket', (data) => {
      if (data.type == '117' /*后端定义常量消息结构：网页刷新审核状态*/) {
        this.getAll()
      }
    })
  },
  methods: {
    getAll() {
      auditRecordAll(this.queryParams).then(response => {
        this.list = response.data
        this.num = response.total
        this.loading = false
      }
      )
    },
    pageChange(page, done) {
      setTimeout(() => {
        this.$message.success('页码' + page)
        this.data = this.data.concat(list)
        done()
      }, 1000)
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
